Skip to content

fix(s): answers and documents are read by shape, never cast - #1598

Open
rudolphpienaar wants to merge 5 commits into
mainfrom
sec/s-b2
Open

rudolphpienaar wants to merge 5 commits into
mainfrom
sec/s-b2

Conversation

@rudolphpienaar

@rudolphpienaar rudolphpienaar commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Stage S, item S5: answers and documents are read by their shape, never cast.

What

  • menu: schemas for the answers surfaces read back (fs.listing, fs.acl, fs.xattr, run.scheduled, plugin instance rows, games trek/chime/show), plus elements_read and fsListings_read: a list is read element by element, so a malformed block, entry or row is left out and named while the rest are kept.
  • argus: the eleven model.data casts (access, cycler, dashboard tiles, tags, answerModel listings, feedRows tags, trek end, and the surface host/session sites split out of main.ts) read through those schemas. A model of the wrong shape reads as no answer and never throws.
  • stratus: now depends on zod. One reader per type in the module that owns it: Terraform plans, cluster/VM keeps, verify records, platform manifests, ChRIS secrets, kept state.json, Red Hat assisted-installer and GoDaddy answers, kube/remote output, harbor-oci checkout. A document that does not read is refused naming the document and the field, never quoting its content (ReadRefusal); lists are read row by row; the nulls Red Hat answers for a new cluster read as absent (SA5).
  • Lint, shape and coverage baselines lowered/raised for the gains.

Why
A cast lets a malformed document through and fails later as undefined, far from its cause; a cast list drops every good row because of one bad one.

Behaviour to note

  • A malformed plan, keep, state or REST answer is now refused by name instead of failing later.
  • A state.json that is no JSON object with a name is refused by its path.

Tests

  • menu answers.test.ts: multi-path listing with surviving rows and partial diagnostics (an always-empty reader fails).
  • argus typedAnswers.test.ts, dashboardTiles.test.ts: per-site wrong-shape and mixed answers; the cycler/dashboard/state cases fail on main's code.
  • stratus readers.test.ts: recorded plans/answers read, wrong-type fields refused by name, secrets never quoted, Red Hat's nulls accepted, kept state refused by its file.
  • Gates green locally: build, lint, lint:shape, lint:modularity, lint:clones, lint:tests, test:ratchets, lint:changesets, lint:seam, lint:lines, lint:coverage-thresholds, lint:host-writes, lint:casts, lint:hostgate, lint:kernel, lint:trek; tests for menu, argus, stratus, chili.

A listing, a feed's access and tags, a run scheduled, a plugin instance row and a game's end each get a schema naming only the fields a surface reads. elements_read and fsListings_read keep the elements that read and name the ones left out, so one malformed block or entry no longer empties an answer.
Eleven sites took an envelope's model.data as whatever they expected. Each now reads it through menu's schemas: a malformed row is left out, a model of the wrong shape reads as no answer and never throws.
Plans, keeps, verify records, manifests, ChRIS secrets, kept state and REST/remote answers are read through zod schemas in the module that owns each type. A document that does not read is refused naming the document and the field, never quoting it; lists are read row by row; the nulls Red Hat answers today read as absent.
@rudolphpienaar rudolphpienaar changed the title sec/s b2 fix(s): answers and documents are read by shape, never cast Dec 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant